home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 September / CHIP Eylül 1998.iso / Slackwar / docs / mini / Mail-Queue < prev    next >
Text File  |  1997-11-15  |  13KB  |  320 lines

  1.   Linux Mail-Queue mini-HOWTO
  2.   Leif Erlingsson, leif@lege.com, Jan P Tietze, jpti¡
  3.   etze@mail.hh.provi.de
  4.   v2.02, 03 September 1997, sendmail 8.8.7
  5.  
  6.   Queue Remote Mail + Deliver Local Mail The Configuration Changes Nec¡
  7.   cessary to Make Sendmail Deliver Local Mail ***Now*** While Stashing
  8.   Remote Mail in The Queue Until "I Say So".
  9.  
  10.   1.  Introduction
  11.  
  12.   The document is written by two authors. The NON dial-on-demand
  13.   solutions part (oldest part) is written by Leif Erlingsson
  14.   <leif@lege.com>, and the newer dial-on-demand solutions part is
  15.   written by Jan P Tietze <jptietze@mail.hh.provi.de>.
  16.  
  17.   2.  NON dial-on-demand solutions PART
  18.  
  19.   Written by Leif Erlingsson <leif@lege.com>.
  20.  
  21.   The original version of this part contained a lot of unnecessary
  22.   stuff.  This is all it takes, really...
  23.  
  24.   2.1.  Starting sendmail
  25.  
  26.   Slackware et al:        /etc/rc.d/rc.M:
  27.  
  28.        echo "Starting sendmail daemon (/usr/sbin/sendmail -bd -os) [queue only mode]..."
  29.        /usr/sbin/sendmail -bd -os      # NOT "-bd -q 15m", the "standard" flags!
  30.  
  31.   RedHat et al:           /etc/rc.d/init.d/sendmail.init:
  32.  
  33.        echo -n "Starting sendmail: [queue only mode]"
  34.        daemon sendmail -bd -os         # NOT daemon sendmail -bd -q1h
  35.  
  36.   The -os is not really essential, all it does is this:
  37.  
  38.        SuperSafe [s] Be super-safe when running things, i.e.,
  39.                always instantiate the queue file,  even  if
  40.                you are going to attempt immediate delivery.
  41.                Sendmail always instantiates the queue  file
  42.                before  returning  control  the client under
  43.                any  circumstances.   This   should   really
  44.                always be set.
  45.  
  46.   This should already be configured in the default sendmail.cf anyway.
  47.  
  48.   2.2.  Configuring sendmail
  49.  
  50.   Serious sendmail users use the m4 source for this. I recommend this
  51.   solution if you ever plan on upgrading sendmail and also make anything
  52.   but trivial changes to sendmail.cf.
  53.  
  54.   If you never intend to fix sendmail so envelope return headers et al
  55.   works even though you might be on dynamic dial in IP or something,
  56.   then you may not need to get the m4 source.
  57.  
  58.   2.2.1.  Configuring sendmail.cf directly, for trivial configurations
  59.  
  60.   This way of doing things is extremeley version dependent vs.
  61.   sendmail.cf versions. The following solution is *only* valid for
  62.   sendmail-8.8.x.
  63.  
  64.   Edit /etc/sendmail.cf:
  65.  
  66.        # avoid connecting to "expensive" mailers on initial submission?
  67.        O HoldExpensive=True
  68.  
  69.        #####  @(#)smtp.m4      8.33 (Berkeley) 7/9/96  #####
  70.  
  71.        Msmtp,          P=[IPC], F=mDFMuXe, S=11/31, R=21, E=\r\n, L=990,
  72.                        T=DNS/RFC822/SMTP,
  73.                        A=IPC $h
  74.        Mesmtp,         P=[IPC], F=mDFMuXae, S=11/31, R=21, E=\r\n, L=990,
  75.                        T=DNS/RFC822/SMTP,
  76.                        A=IPC $h
  77.        Msmtp8,         P=[IPC], F=mDFMuX8e, S=11/31, R=21, E=\r\n, L=990,
  78.                        T=DNS/RFC822/SMTP,
  79.                        A=IPC $h
  80.        Mrelay,         P=[IPC], F=mDFMuXa8e, S=11/31, R=61, E=\r\n, L=2040,
  81.                        T=DNS/RFC822/SMTP,
  82.                        A=IPC $h
  83.  
  84.   The important flag above is ``e''. Don't fuss if the other flags look
  85.   different in your file. Keep your flags as-is, only add ``e'' to your
  86.   flags according to the above examples, unless it's there already.
  87.   ``e'' marks the mailers as ``expensive''.
  88.  
  89.   2.2.2.  Configuring sendmail.cf using m4 source
  90.  
  91.   In the following I will, for simplicity, assume that the sendmail
  92.   version is 8.8.7. If you have a different version, replace 8.8.7 with
  93.   that version number below! Also, the instructions will not work for
  94.   older versions of sendmail. Get the latest sendmail!
  95.  
  96.   Download the sendmail source.  Try ``http://WWW.Sendmail.ORG'' or
  97.   possibly ``ftp.sendmail.org''.
  98.  
  99.   I also recommend that you obtain my patch for allowing envelope sender
  100.   reverse aliasing and other nice stuff to really make you take control
  101.   over your mail environment.
  102.  
  103.   Write to ``Sendmail Patch <sendmail@lege.com>'', Subject:
  104.   ``sendmail-8.8.7'', if 8.8.7 is your sendmail version.
  105.  
  106.   They are also available from ``http://www.lege.com'', as is the sgml
  107.   source of this mini-HOWTO!
  108.  
  109.   You don't have to get my patches in order to get ``Queue Remote Mail +
  110.   Deliver Local Mail'' to work. My patches solve other things. But I
  111.   just thought this would be a nice place to mention them, as many Linux
  112.   users will find them extremely useful.  (They will even give you
  113.   properly working virtual domains, if you like. The virtual domains
  114.   don't have to be ``local''. They will give you ``xaliases'', or in
  115.   other words ``reverse aliasing''.)
  116.  
  117.   Unpack the sendmail source. You may get /usr/src/sendmail-8.8.7/.  cd
  118.   /usr/src/sendmail-8.8.7/cf
  119.  
  120.   Now overlay my patch, if you want it, otherwise skip this step: If you
  121.   don't want to use procmail as Local Delivery Agent, save away your
  122.   /usr/src/sendmail-8.8.7/cf/ostype/linux.m4 before doing this...  Save
  123.   my patch to ``/tmp/sendmail-8.8.7-cf-cpio-idcmu.gz'', then...
  124.  
  125.        cd /usr/src/sendmail-8.8.7/cf
  126.        gzip -dc < /tmp/sendmail-8.8.7-cf-cpio-idcmu.gz | cpio -idcmu
  127.  
  128.   If you didn't want to use procmail, write back the saved copy of
  129.   /usr/src/sendmail-8.8.7/cf/ostype/linux.m4 again.
  130.  
  131.   And regardless of if you applied my patch or not, you must make sure
  132.   these lines or very similar ones are added to
  133.   /usr/src/sendmail-8.8.7/cf/cf/yourhostname.smtp.mc (but if you applied
  134.   my patch you may want to investigate filenames containing the word
  135.   ``elijah'', under /usr/src/sendmail-8.8.7/cf):
  136.  
  137.        dnl # Defer Delivery to "expensive" mailers until next time the
  138.        dnl # queue is processed using "O HoldExpensive=True" and make
  139.        dnl # sure smtp mailers are "expensive".
  140.        dnl # (See original "sendmail" book Chapter 30: Options,
  141.        dnl # "Oc - Don't connect to expensive mailers", or
  142.        dnl # 2nd Edition "sendmail" book Chapter 34.8.29,
  143.        dnl # "HoldExpensive (c), Queue for expensive mailers".)
  144.        dnl #                           / Leif Erlingsson <leif@lege.com>
  145.        define(`confCON_EXPENSIVE', `True')
  146.        define(SMTP_MAILER_FLAGS, e)
  147.        MAILER(local)dnl
  148.        MAILER(smtp)dnl
  149.  
  150.   2.3.  Menu support suggestions
  151.  
  152.   The 1.x versions of this document contained Menu support suggestions
  153.   for /var/X11R6/lib/fvwm/system.fvwmrc. I have dropped those in the
  154.   current version, but they are available on request:
  155.  
  156.   Write to ``Menu support suggestions <fvwmrc@lege.com>'', Subject:
  157.   ``Menu support suggestions''
  158.  
  159.   3.  Dial-on-demand solutions PART
  160.  
  161.   Written by Jan P Tietze <jptietze@mail.hh.provi.de>.
  162.  
  163.   Many Linux users access the Internet through a dialup line, and many
  164.   have decided to implement dial-on-demand facilities on their system.
  165.   That is, whenever an IP packet of some sort has to leave the local
  166.   network or the local host, the link to an Internet Service Provider
  167.   (ISP) will automatically be established. The link will be dropped
  168.   after some period of time that no packet has travelled across.
  169.  
  170.   Although this is very comfortable and cost effective, there is one
  171.   special case in which this is neither comfortable (as the time to
  172.   bring up a "traditional" modem dialup is very noticeable) nor cost
  173.   effective, and this is sending e-mail. E-Mail is commonly sent by
  174.   SMTP, either delivered by your own system or through a SMTP host on
  175.   the Internet that usually resides in your ISP's network.
  176.  
  177.   With dialup lines, every time you send a message the link will have to
  178.   be brought up. This is quite okay if you send only one message, but if
  179.   you happen to create and send multiple messages, bringing up the line
  180.   more than once can be tedious and cost ineffective. Also, if your ISP
  181.   imposes limits as to what times you are allowed to login, this would
  182.   also restrict you to postpone messages at certain times of the day,
  183.   and you would have to manually send them later.
  184.  
  185.   Section 1 of this document will solve the situation, however in
  186.   situations where an external DNS lookup would cause the link up, the
  187.   link will still be established even if e-mail is just being queued.
  188.   The reason is that sendmail wishes to "canonify" host names.
  189.  
  190.   The solution to this problem is twofold: First, we'll have to
  191.   moderately change sendmail.cf. And then we have to define the process
  192.   of actual mail delivery. Personally, I prefer to have cron do the job
  193.   for me and describe the necessary changes below.
  194.  
  195.   3.1.  Configuring sendmail.cf
  196.  
  197.   For the reasons stated in 1.2, I recommend modifying the m4 sources
  198.   instead of editing sendmail.cf directly. It will actually save you a
  199.   lot of hassle and make configuration changes more verbose.
  200.  
  201.   First, perform all the changes described in the first part of this
  202.   document. Then go through the dial-on-demand specific stuff.
  203.  
  204.   3.1.1.  Configuring sendmail.cf directly, for trivial configurations
  205.  
  206.   Configuring directly is highly impractical and anything but verbose,
  207.   but obviously, this is your decision.
  208.  
  209.   Close to very bottom of your sendmail.cf should be a line that reads:
  210.  
  211.        R$* < @ $* $~P > $*             $: $1 < @ $[ $2 $3 $] > $4
  212.  
  213.   Precede that line with a "#" so that it reads
  214.  
  215.        #R$* < @ $* $~P > $*            $: $1 < @ $[ $2 $3 $] > $4
  216.  
  217.   3.1.2.  Configuring sendmail.cf using the m4 source.
  218.  
  219.   Add the following line to
  220.   /usr/src/sendmail-8.8.7/cf/cf/yourhostname.smtp.mc:
  221.  
  222.        FEATURE(nocanonify)dnl
  223.  
  224.   Your final sendmail.cf can then be built by issuing the following
  225.   commands. Remember to always back up your old /etc/sendmail.cf before
  226.   installing the new one:
  227.  
  228.        cp /etc/sendmail.cf /etc/sendmail.cf.bak
  229.        cd /usr/src/sendmail-8.8.7/cf/cf
  230.        m4 yourhostname.smtp.mc > /etc/sendmail.cf
  231.  
  232.   3.2.  Adding dial delay
  233.  
  234.   It is oftentimes useful, especially when using modem lines, to have a
  235.   dial delay installed. This means that if sendmail tries to initiate a
  236.   connection in an attempt to send an e-mail (and this causes the line
  237.   to go up) but the link actually takes more time to get established
  238.   than what sendmail thinks should be a reasonable timeout, sendmail
  239.   will simply wait some seconds and then retry.
  240.  
  241.   3.2.1.  Configuring sendmail.cf directly
  242.  
  243.   Somewhere in your sendmail.cf could be a line that would read:
  244.  
  245.        #O DialDelay=10s
  246.  
  247.   (or very similar). Delete the ``#''. If there's no ``#'' at the
  248.   beginning of the line, things should be considered okay (it just means
  249.   this had already been enabled before).
  250.  
  251.   If there is no such line in your sendmail.cf, add one (it is a wise
  252.   thing to do to add this in the "options" part of the file):
  253.  
  254.        O DialDelay=10s
  255.  
  256.   Now change the ``10s'' part to the number of seconds you deem
  257.   suitable.
  258.  
  259.   3.2.2.  Configuring sendmail.cf using m4 source
  260.  
  261.   Add the following line to
  262.   /usr/src/sendmail-8.8.7/cf/cf/yourhostname.smtp.mc:
  263.  
  264.        define(`confDIAL_DELAY',`10s')
  265.  
  266.   Now change the ``10s'' part to the number of seconds you deem
  267.   suitable.
  268.  
  269.   Your final sendmail.cf can then be built by issuing the following
  270.   commands. Remember to always back up your old /etc/sendmail.cf before
  271.   installing the new one:
  272.  
  273.        cp /etc/sendmail.cf /etc/sendmail.cf.bak
  274.        cd /usr/src/sendmail-8.8.7/cf/cf
  275.        m4 yourhostname.smtp.mc > /etc/sendmail.cf
  276.  
  277.   4.  Delivering e-mail
  278.  
  279.   E-Mail delivery can be invoked by issuing the command "sendmail -q".
  280.   For those who are interested in what sendmail actually does, "sendmail
  281.   -q -v" will give a more verbose version of the delivery process.
  282.  
  283.   It is very convenient to automate the process of e-mail delivery. A
  284.   tool commonly used for this process is cron.
  285.  
  286.   4.1.  How to have e-mail delivered at special times.
  287.  
  288.   Edit your crontab:
  289.  
  290.        crontab -e
  291.  
  292.   Add lines of the form:
  293.  
  294.        05 18-23,0-7    * * Mon,Tue,Wed,Thu,Fri /usr/sbin/sendmail -q
  295.        05 *            * * Sat,Sun             /usr/sbin/sendmail -q
  296.  
  297.   Please refer to the crontab man page (available through "man 5
  298.   crontab") for further information. I think the format is pretty
  299.   obvious. The example crontab entries shown above send e-mail (if, and
  300.   only if, e-mail is available from the queue) 5 minutes after an hour
  301.   on weekdays, starting at 6:05 pm, and stopping at 7:05 am.  On
  302.   weekends, e-mail is delivered 5 minutes after an hour, starting at
  303.   12:05 pm on Saturday, and stopping 11:05 pm on Sunday.
  304.  
  305.   As a dial-on-demand user, it is sometimes desirable to have your
  306.   system collect your e-mail via the POP3 protocol at certain times of
  307.   the day. You could therefore add an entry similar to the following to
  308.   your crontab:
  309.  
  310.        0 21            * * * popclient -3 -u <your pop3 user name
  311.        goes here> -p <put your password here> -o /var/spool/mail/<the user
  312.        on your system that should receive the collected e-mail>
  313.        <mailhost.somedomain.com>
  314.  
  315.   Of course, this should all go on a single line.
  316.  
  317.   Then, save the file and leave the editor. The crontab should now be
  318.   installed.
  319.  
  320.